<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet" href="<%=commonPath %>/pageRc/layui/css/layui.css" media="all">
<link rel="stylesheet" href="<%=commonPath %>/pageRc/css/manlogin/admin.css" media="all">
<link rel="stylesheet" href="<%=commonPath %>/pageRc/css/manlogin/login.css" media="all">
<link id="layuicss-layer" rel="stylesheet" href="<%=commonPath %>/pageRc/css/manlogin/layer.css" media="all">
<link rel="stylesheet" href="<%=commonPath %>/pageRc/css/manlogin/layui.css" media="all">
<script type="text/javascript" src="<%=commonPath %>/pageRc/js/jquery-1.9.1.min.js"></script> 
<script type="text/javascript" src="<%=commonPath %>/pageRc/layui/layui.js"></script>
<script type="text/javascript" src="<%=commonPath %>/pageRc/common/utils.js"></script>
<script type="text/javascript" src="<%=commonPath %>/pageRc/common/msgTool.js"></script>

<title>修改密码</title>
<style type="text/css">
.layui-main{
   width: 300px;
}
</style>
<script>
$(function(){
	
})
var path="<%=commonPath%>";
var msg = new msgTool();
layui.use(
		[ 'form', 'layer', 'laytpl', 'laypage','laydate' ],
		function() {
			var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	        var form = layui.form()
	            ,layer = layui.layer
	            ,laypage = layui.laypage
	            ,laytpl = layui.laytpl; 
		
	       
		});

	//前端部分：输入选项是否为空，原密码是否和新密码一致，新密码的格式要求（长度，字符类型等）
	//后端部分：原密码的正确与否应该放在这里校验，保证数据安全。
	//另外。前端校验过的信息。最好是在后端也重新校验一次
	function confirm(){
		//数据库密码
		var oldPassWord=$("#oldPassWord").val();
		var userNo=$("#userNo").val();
		//页面输入的原密码
		var oldPwd = $("#oldPwd").val();   
		var newPwd = $("#newPwd").val();
		var confirmPwd = $("#confirmPwd").val(); 
	if(oldPwd!=""&&newPwd!=""&&confirmPwd!="")	{
		if(newPwd.trim().length<6||newPwd.trim().length>12){
			layer.tips('密码长度要6-12位！', '#newPwd', {
		   		  tips: [2, '#FF3030'],
		   		  area: ['150px', '35px'],
		   		  time: 2000
		   		});
			return false;
			}
		 if(newPwd!=confirmPwd){
			layer.tips('两次密码不相同！', '#confirmPwd', {
		   		  tips: [2, '#FF3030'],
		   		  area: ['150px', '35px'],
		   		  time: 2000
		   		});
			return false;
		} 
		/*  if(oldPwd!=oldPassWord){
				layer.tips('原密码错误！', '#oldPwd', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '35px'],
			   		  time: 2000
			   		});
				return false;
			}  */
		 //数据没问题后提交并发送请求
		   var dataObj = {
				"userNo" : userNo,
				"confirmPwd" : confirmPwd,
				"pwd":oldPwd,
				"upassWord":oldPassWord
				};
		msg.sendMsg("/page/main/updatePassWord.do",dataObj,function(data) {
			if(data.body=="OK"){
	          parent.location.href ="<%=commonPath%>/page/main/manager.do?state=logout";
			}
			if(data.body=="False"){
				layer.tips('原密码错误！', '#oldPwd', {
			   		  tips: [2, '#FF3030'],
			   		  area: ['150px', '35px'],
			   		  time: 2000
			   		});
			}			
		});
	  } 
	
	
	}
	

</script>
</head>
<body class="layui-main">

<input type="hidden" id="oldPassWord" value="${userBean.getUpassWord() }">
<input type="hidden" id="userNo" value="${userBean.getUserNo() }">
     <!--修改密码-->
    	<div class="layadmin-user-login-main">
			<div class="layadmin-user-login-box layadmin-user-login-header">
				<h2>联信科技</h2>
			</div>
			<div
				class="layadmin-user-login-box layadmin-user-login-body layui-form">
				<div class="layui-form-item">
					<label
						class="layadmin-user-login-icon layui-icon layui-icon-form"
						for="LAY-user-login-username"></label> <input type="password"
						name="oldPwd" id="oldPwd" lay-verify="required"
						placeholder="原密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label
						class="layadmin-user-login-icon layui-icon layui-icon-form"
						for="LAY-user-login-password"></label> <input type="password"
						name="newPwd" id="newPwd" lay-verify="required"
						placeholder="新密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<label
						class="layadmin-user-login-icon layui-icon layui-icon-form"
						for="LAY-user-login-password"></label> <input type="password"
						name="confirmPwd" id="confirmPwd" lay-verify="required"
						placeholder="确认新密码" class="layui-input">
				</div>
				<div class="layui-form-item">
					<button class="layui-btn layui-btn-fluid" lay-submit=""
						lay-filter="LAY-user-login-submit" onclick="confirm()">确认</button>
				</div>
			</div>
		</div>

</body>

</html>